package com.kinyx.framework.log;

import java.util.Map;
import java.util.Properties;

import javax.util.XHashMap;

import com.kinyx.framework.file.KPropertiesReader;
import com.kinyx.framework.utils.KEnumUtils;
import com.kinyx.framework.utils.KMapUtils;

interface Configs {

	/** 根级别 */
	String ROOT = "ROOT";

	/** 配置属性 */
	Properties PROPERTIES = KPropertiesReader.read("configs-log.properties");

	/** 配置属性 */
	Properties PROPERTIES_IMPL = KPropertiesReader.read("configs-log-impl.properties");

	/** 日志标识 */
	String logTag = KPropertiesReader.getStringValue(PROPERTIES, "log.tag", "kinyx");

	/** 日志级别 */
	Map<String, LogLevel> levels = KMapUtils.convert(KPropertiesReader.getMapValue(PROPERTIES, "log.levels", new XHashMap<String, String>()//
			.xPut(ROOT, LogLevel.debug.toString())//
			.xPut("org", LogLevel.info.toString())//
			.xPut("net", LogLevel.info.toString())//
			.xPut("io", LogLevel.info.toString())//
			, "&", "="), value -> {
				return KEnumUtils.compare(LogLevel.class, e -> {
					return e.toString().toLowerCase().equals(value.toLowerCase());
				});
			});

	/** 日志工厂实现类 */
	@SuppressWarnings("unchecked")
	Class<? extends LogFactory<?>> LogFactoryClass = (Class<? extends LogFactory<?>>) KPropertiesReader.getClassValue(PROPERTIES_IMPL, "log.LogFactory", LogFactory4Console.class);

}
